<?php

namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Doctrine\DBAL\Driver\IBMDB2\DB2Connection;
use PDO;

class DefaultController extends Controller
{
    /**
     * @Route("/", name="homepage")
     */
    public function indexAction(Request $request)
    {
        /** @var DB2Connection $conn */
        $conn = $this->get('database_connection');

//        $insert = $conn->prepare(
//            "INSERT INTO STAFF(ID, NAME, DEPT, JOB, YEARS, SALARY, COMM) "
//            . "VALUES"
//            . "(351, 'San.Zhang', 100, 'Clerk', 3, 76858.2, 844),"
//            . "(352, 'Si.Li', 101, 'Clerk', 3, 30000, 1000)"
//        );
//        $insert->execute();

        $sth = $conn->prepare("SELECT * FROM TZ_CGB_BMCRM_LOG");
//        $sth->bindValue(1, 351, PDO::PARAM_INT);
        $sth->execute();
        $users = $sth->fetchAll();

        // replace this example code with whatever you need
        return $this->render('default/index.html.twig', [
            'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
            'users' => $users
        ]);
    }
}
